#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace StreamEye {

	/// <summary>
	/// Summary for PidList
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class PidList : public System::Windows::Forms::Form
	{
	public:
		PidList(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~PidList()
		{
			if (components)
			{
				delete components;
			}
		}

	protected: 





















































	private: System::Windows::Forms::BindingSource^  mainFormBindingSource;
	private: System::Windows::Forms::DataGridView^  dataGridView1;




	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column1;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column2;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Column3;



	private: System::ComponentModel::IContainer^  components;

	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
			this->mainFormBindingSource = (gcnew System::Windows::Forms::BindingSource(this->components));
			this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->Column1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Column2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Column3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->mainFormBindingSource))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->BeginInit();
			this->SuspendLayout();
			// 
			// dataGridView1
			// 
			this->dataGridView1->AllowUserToAddRows = false;
			this->dataGridView1->AllowUserToDeleteRows = false;
			this->dataGridView1->AllowUserToOrderColumns = true;
			this->dataGridView1->AllowUserToResizeRows = false;
			this->dataGridView1->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill;
			this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
			this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(3) {this->Column1, 
				this->Column2, this->Column3});
			dataGridViewCellStyle1->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
			dataGridViewCellStyle1->BackColor = System::Drawing::SystemColors::Window;
			dataGridViewCellStyle1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, 
				System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(204)));
			dataGridViewCellStyle1->ForeColor = System::Drawing::SystemColors::ControlText;
			dataGridViewCellStyle1->SelectionBackColor = System::Drawing::SystemColors::Highlight;
			dataGridViewCellStyle1->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
			dataGridViewCellStyle1->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
			this->dataGridView1->DefaultCellStyle = dataGridViewCellStyle1;
			this->dataGridView1->Dock = System::Windows::Forms::DockStyle::Top;
			this->dataGridView1->Location = System::Drawing::Point(0, 0);
			this->dataGridView1->Name = L"dataGridView1";
			this->dataGridView1->ReadOnly = true;
			this->dataGridView1->RowHeadersVisible = false;
			this->dataGridView1->Size = System::Drawing::Size(303, 340);
			this->dataGridView1->TabIndex = 0;
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(33, 391);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(75, 23);
			this->button2->TabIndex = 2;
			this->button2->Text = L"Close";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &PidList::button2_Click);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(13, 347);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(0, 13);
			this->label1->TabIndex = 3;
			// 
			// Column1
			// 
			this->Column1->HeaderText = L"PID";
			this->Column1->Name = L"Column1";
			this->Column1->ReadOnly = true;
			// 
			// Column2
			// 
			this->Column2->HeaderText = L"Count";
			this->Column2->Name = L"Column2";
			this->Column2->ReadOnly = true;
			// 
			// Column3
			// 
			this->Column3->HeaderText = L"Description";
			this->Column3->Name = L"Column3";
			this->Column3->ReadOnly = true;
			// 
			// PidList
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(303, 426);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->dataGridView1);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
			this->MinimizeBox = false;
			this->Name = L"PidList";
			this->ShowInTaskbar = false;
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"PID List";
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->mainFormBindingSource))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
				 this->Close();
			 }
	 public: void setTable(array<String^, 2>^ sourceTable, int pidsNumber) {
				 String^ descr = "";
				 for (int i=0; i<pidsNumber; i++) {
					 if ((sourceTable[i,0] == "0x0000") | (sourceTable[i,0] == "0")) descr = "PAT";
					 else if ((sourceTable[i,0] == "0x0001") | (sourceTable[i,0] == "1")) descr = "CAT";
					 else if ((sourceTable[i,0] == "0x0002") | (sourceTable[i,0] == "2")) descr = "TSDT";
					 
					 else if ((sourceTable[i,0] == "0x0010") | (sourceTable[i,0] == "16")) descr = "NIT,ST";
					 else if ((sourceTable[i,0] == "0x0011") | (sourceTable[i,0] == "17")) descr = "SDT,BAT,ST";
					 else if ((sourceTable[i,0] == "0x0012") | (sourceTable[i,0] == "18")) descr = "EIT,ST";
					 else if ((sourceTable[i,0] == "0x0013") | (sourceTable[i,0] == "19")) descr = "RST,ST";
					 else if ((sourceTable[i,0] == "0x0014") | (sourceTable[i,0] == "20")) descr = "TDT,TOT,ST";
					 else if ((sourceTable[i,0] == "0x0015") | (sourceTable[i,0] == "21")) descr = "SYNC";
					 else if ((sourceTable[i,0] == "0x0016") | (sourceTable[i,0] == "22")) descr = "RNT";
					 
					 else if ((sourceTable[i,0] == "0x001C") | (sourceTable[i,0] == "28")) descr = "MANAGE,CONTROL";
					 else if ((sourceTable[i,0] == "0x001D") | (sourceTable[i,0] == "29")) descr = "MEASUREMENTS";
					 else if ((sourceTable[i,0] == "0x001E") | (sourceTable[i,0] == "29")) descr = "DIT";
					 else if ((sourceTable[i,0] == "0x001F") | (sourceTable[i,0] == "29")) descr = "SIT";

					 else if ((sourceTable[i,0] == "0x1FFF") | (sourceTable[i,0] == "8191")) descr = "NULL";
					 else descr = "";
					 dataGridView1->Rows->Add(sourceTable[i,0],sourceTable[i,1], descr);
				 }

				 label1->Text = pidsNumber.ToString() + " PIDs used";
			  }
};
}
